﻿	var swfu;
	var myParams;
	var fkt = 'jfzc_reportinfo';
	var fkv;
	var areatree_window;
	var areaid;
	var area_flag;
	var allpath = 'https://jfts.mos.gov.cn';
	
	//Ext.onReady(function() {
	//	//parent.document.getElementById('pos').innerHTML = '填写举报信';
	//	Ext.BLANK_IMAGE_URL = '/jfzc/js/extjs/resources/images/default/s.gif';
		
	//	var clicktreenodetext = '';
	//	var clicktreenodeorgcode = '';
	//	var tree = new Ext.tree.TreePanel({
	//      	xtype: 'treepanel',
	//     	border: false,
	//		lines: false,
	//		id: "tree",
	//		cls:'STYLE3',
	//		rootVisible: true,
	//		autoScroll: true,
	//		root: new Ext.tree.AsyncTreeNode({
	//			text: "行政区划树",
	//	        draggable: false,
	//	        id:"sys:",
	//	        cls:'STYLE3',
	//	        expanded: false
	//		}),
	//      	listeners:
	//      	{
	//         	'beforeload' : function(node) {
	//            	if(typeof(node.text) != "undefined") {
	//               		node.loader = new Ext.tree.TreeLoader({
	//                  	dataUrl:allpath + '/areatree/AreaListServlet',
	//                 	baseParams :
	//                  	{
	//                     	'level': node.attributes.level,
	//                     	'id': node.id
	//                  	}
	//               	});
	//            	}
	//         	},
	//         	'click': function(node) {
	//         		if(node.attributes.level == '1') {
	//         			clicktreenodetext = node.text;
	//         			clicktreenodeorgcode = node.attributes.orgcode;
	//         		} else if(node.attributes.level == '2') {
	//         			clicktreenodetext = node.parentNode.text + '-' + node.text;
	//         			clicktreenodeorgcode = node.parentNode.attributes.orgcode + ',' + node.attributes.orgcode;
	//         		} else if(node.attributes.level == '3') {
	//         			clicktreenodetext = node.parentNode.parentNode.text + '-' + node.parentNode.text + '-' + node.text;
	//         			clicktreenodeorgcode = node.parentNode.parentNode.attributes.orgcode + ',' + node.parentNode.attributes.orgcode + ',' + node.attributes.orgcode;
	//         		}
	//         		buildPersonChoseGrid(clicktreenodetext, clicktreenodeorgcode, node.attributes.level);
	//         	}
	//      	}
	//   	});
	   	
	//   	var areatree_form = new Ext.form.FormPanel({
	//		autoHeight: true,
	//		id: 'areatree_form',
	//		layout: 'column',
	//		frame: 'true',
	//		html: 	'<table width="690" border="0" cellspacing="0" cellpadding="0" style="line-height: 25px; text-align: left;">' +
	//				'<tr>' +
	//				'<td class="s05">' +
	//				'<B>省份：</B>' +
	//				'</td>' +
	//				'<td>' +
	//				'<select class="select2" id="provinceid" name="provinceid" onchange="provinceChange(this.value)" style="float:none"><option value="">请选择省</option></select>' +
	//				'</td>' +
	//				'</tr>' +
	//				'<tr>' +
	//				'<td class="s05">' +
	//				'<B>市/地区：</B>' +
	//				'</td>' +
	//				'<td>' +
	//				'<select class="select2" id="cityid" name="cityid" onchange="cityChange(this.value)" style="float:none"><option value="">请选择城市</option></select>' +
	//				'</td>' +
	//				'</tr>' +
	//				'<tr>' +
	//				'<td class="s05">' +
	//				'<B>县：</B>' +
	//				'</td>' +
	//				'<td>' +
	//				'<select class="select2" id="countryid" name="countryid" style="float:none"><option value="">请选择县</option></select>' +
	//				'</td>' +
	//				'</tr>' +
	//			  	'</table>'
	//	});
   	    
   	//	areatree_window = new Ext.Window({
	//   		title: "选择行政区划",
	//   		width: 350,
	//		height: 170,
	//		layout: "fit",
	//		plain: true,
	//	 	resizable: false,
	//		modal: true,
	//		constrain: true,
	//	 	bodyStyle: 'padding:5px;',
	//	 	buttonAlign: 'center',
	//	 	closeAction: 'hide',
	//		buttonAlign: 'center',
	//		items:[areatree_form],
	//		y:"200px",
	//		buttons:[
	//			{
	//    	 		text: '确认',handler:function() {
	//    	 			myArea();
	//    	 		}
	//    	 	},
	//			{
	//   	 			text: '关闭', handler: function() {
	//		 			areatree_window.hide();
	//		 		}
	//   	 		}
	//		]
	//   	});
		
	//});
	
	/**文本域长度判断**/
	function checkLength(obj, max) {
		if(trim(obj.value).length > max) {
            alert("请不要超过最大长度:" + max);
            obj.value = obj.value.substring(0, max);
            return;
        }
	}
	
	function show_areatree(id, flag) {
		areaid = id;
		area_flag = flag;
		areatree_window.show();
		Ext.Ajax.request({
			url: allpath + '/areatree/AreaListServlet',
			callback: function(options, success, response) { //ajax是异步的,所以要声明一个回调函数
				if(!success) {
					alert('error!');
					return;
				} else {
					var rsp = Ext.util.JSON.decode(response.responseText);
  					var datas = Array.prototype.slice.call(rsp);
  					Z.html.Select.bindData("provinceid", datas, "text", "id", "请选择省", true);
  					
  					document.getElementById('cityid').options.length = 0;
					var oOption = new Option('请选择城市', '');
					document.getElementById('cityid').options[document.getElementById('cityid').options.length] = oOption;
					document.getElementById('cityid').selectedIndex = document.getElementById('cityid').options.length - 1;
				
					document.getElementById('countryid').options.length = 0;
					var oOption = new Option('请选择县', '');
					document.getElementById('countryid').options[document.getElementById('countryid').options.length] = oOption;
		       		document.getElementById('countryid').selectedIndex = document.getElementById('countryid').options.length - 1;
				}
			}
		});
		//window.open("http://localhost:9080/areatree/jsp/tree.jsp");
	}
	
	function provinceChange(id) {
		if(id != '') {
			Ext.Ajax.request({
				url: allpath + '/areatree/AreaListServlet?level=1&id='+id,
				callback: function(options, success, response) { //ajax是异步的,所以要声明一个回调函数
					if(!success) {
						alert('error!');
						return;
					} else {
						if(trim(response.responseText) != '') {
							var rsp = Ext.util.JSON.decode(response.responseText);
		  					var datas = Array.prototype.slice.call(rsp);
		  					Z.html.Select.bindData("cityid", datas, "text", "id", "请选择城市", true);
						} else {
							document.getElementById('cityid').options.length = 0;
							var oOption = new Option('请选择城市', '');
							document.getElementById('cityid').options[document.getElementById('cityid').options.length] = oOption;
							document.getElementById('cityid').selectedIndex = document.getElementById('cityid').options.length - 1;
						}
						document.getElementById('countryid').options.length = 0;
		  				var oOption = new Option('请选择县', '');
						document.getElementById('countryid').options[document.getElementById('countryid').options.length] = oOption;
			        	document.getElementById('countryid').selectedIndex = document.getElementById('countryid').options.length - 1;
					}
				}
			});
		} else {
			document.getElementById('cityid').options.length = 0;
			var oOption = new Option('请选择城市', '');
			document.getElementById('cityid').options[document.getElementById('cityid').options.length] = oOption;
			document.getElementById('cityid').selectedIndex = document.getElementById('cityid').options.length - 1;
		
			document.getElementById('countryid').options.length = 0;
			var oOption = new Option('请选择县', '');
			document.getElementById('countryid').options[document.getElementById('countryid').options.length] = oOption;
       		document.getElementById('countryid').selectedIndex = document.getElementById('countryid').options.length - 1;
		}
	}
	
	function cityChange(id) {
		if(id != '') {
			Ext.Ajax.request({
				url: allpath + '/areatree/AreaListServlet?level=2&id='+id,
				callback: function(options, success, response) { //ajax是异步的,所以要声明一个回调函数
					if(!success) {
						alert('error!');
						return;
					} else {
						if(trim(response.responseText) != '') {
							var rsp = Ext.util.JSON.decode(response.responseText);
	  						var datas = Array.prototype.slice.call(rsp);
	  						Z.html.Select.bindData("countryid", datas, "text", "id", "请选择县", true);
						} else {
							document.getElementById('countryid').options.length = 0;
							var oOption = new Option('请选择县', '');
							document.getElementById('countryid').options[document.getElementById('countryid').options.length] = oOption;
				       		document.getElementById('countryid').selectedIndex = document.getElementById('countryid').options.length - 1;
						}
					}
				}
			});
		} else {
			document.getElementById('countryid').options.length = 0;
			var oOption = new Option('请选择县', '');
			document.getElementById('countryid').options[document.getElementById('countryid').options.length] = oOption;
       		document.getElementById('countryid').selectedIndex = document.getElementById('countryid').options.length - 1;
		}
	}
	
	function myArea() {
		var text = '';
		var province_obj = document.getElementById('provinceid');
		if(province_obj.length > 0 && province_obj.value != '') {
			for(var i = 0; i < province_obj.length; i++) {
				if(province_obj[i].selected == true) {
					text = province_obj[i].innerText;
					continue;
				}
			}
		}
		var province_code = '';
		if(province_obj.value != '') {
			province_code = province_obj.value.split('_')[0];
		}
		
		var city_obj = document.getElementById('cityid');
		if(city_obj.length > 0 && city_obj.value != '') {
			for(var i = 0; i < city_obj.length; i++) {
				if(city_obj[i].selected == true) {
					text += '-' + city_obj[i].innerText;
				}
			}
		}
		var city_code = '';
		if(city_obj.value != '') {
			city_code = city_obj.value.split('_')[0];
		}
		
		var country_obj = document.getElementById('countryid');
		if(country_obj.length > 0 && country_obj.value != '') {
			for(var i = 0; i < country_obj.length; i++) {
				if(country_obj[i].selected == true) {
					text += '-' + country_obj[i].innerText;
				}
			}
		}
		var country_code = '';
		if(country_obj.value != '') {
			country_code = country_obj.value.split('_')[0];
		}
		
		if(text == '') {
			alert('请选择省!');
			return false;
		} else {
			if(area_flag) {
				document.getElementById('province_code').value = province_code;
				document.getElementById('city_code').value = city_code;
				document.getElementById('country_code').value = country_code;
				document.getElementById('areacode').value = province_code;
			}
			document.getElementById(areaid).value = text;
			areatree_window.hide();
		}
	}

	function buildPersonChoseGrid(text, code, level) {
		if(area_flag) {
			document.getElementById('province_code').value = '';
			document.getElementById('city_code').value = '';
			document.getElementById('country_code').value = '';
			document.getElementById('areacode').value = '';
			if(level != '1') {
				var orgcode = code.split(',');
				if(orgcode != null && orgcode.length > 0) {
					for(var i = 0; i < orgcode.length; i++) {
						if(i == 0) {
							document.getElementById('province_code').value = orgcode[0];
							document.getElementById('areacode').value = orgcode[0];
						} else if(i == 1) {
							document.getElementById('city_code').value = orgcode[1];
						} else if(i == 2) {
							document.getElementById('country_code').value = orgcode[2];
						}
					}
				}
			} else {
				document.getElementById('province_code').value = code;
				document.getElementById('areacode').value = code;
			}
		}
		document.getElementById(areaid).value = text;
		areatree_window.hide();
	}
	
	function changeQuestion(v) {
		window.status = v;
		document.getElementById('questionclassification').title = v;
	}
	
	/**页面提交**/
	function mysave(state) {
		var o = { xxx: 999 };
		//封装页面所有元素
		var myParams = Z.getUI2Params('mytable', o, true, null);
		if(myParams.happenaddr == '') {
			alert('问题所属地不能为空!');
			Z.focus('happenaddr');
			return false;
		} else if(myParams.complaintunits == '') {
			alert('被反映人(单位)不能为空!');
			Z.focus('complaintunits');
			return false;
		} else if(myParams.reportObjectId == '') {
			alert('被反映对象不能为空!');
			return false;
		} else if(myParams.reportQuestionId1 == '') {
			alert('问题类别不能为空!');
			return false;
		} else if(myParams.questionclassification == '') {
			alert('问题细类不能为空!');
			return false;
		} else if(myParams.lettertitle == '') {
			alert('信件标题不能为空!');
			Z.focus('lettertitle');
			return false;
		} else if(myParams.txtContent == '') {
			alert('信件主要问题不能为空!');
			return false;
		} else if(myParams.txtContent.length < 20) {
			alert('信件主要问题不能小于20字!');
			return false;
		} else {
			var sel = document.getElementById('reportObjectId');
			myParams.reportObject = sel.options[sel.options.selectedIndex].innerHTML;
			myParams.lettercontent = myParams.txtContent;
			myParams.state = state;
			Ext.Ajax.request({
				url: allpath + '/jfzc/reportInfoAction.do?method=noregister_save_data',
		        params: myParams,
		        callback: function(options, success, response) { //ajax是异步的,所以要声明一个回调函数
		        	if(success) {
		        		fkv = trim(response.responseText);
						if(fkv == 'more') {
							alert('每周限制举报2次，请勿重复举报！');
							return false;
						} else if(fkv == 'no') {
							alert('您所提交的信件内容，已有80%的重复率进行过操作！');
							return false;
						} else {
							if(swfu.getStats().files_queued > 0) {
								swfu.setUploadURL(allpath + '/jfzc/uploadAction.do?method=file_upload&fkv='+fkv+'&fkt='+fkt);
								swfu.startUpload();
							} else {
								//alert('谢谢您对纠风工作的关注，您的'+myParams.lettercategory+'已提交成功！');
								alert('感谢对我们工作的关注与支持！');
								window.location.href = './reportView.html?id='+fkv;
							}
						}
		        	} else {
			            alert("添加失败!");
			        }
		        }
			});
		}
	}

	function change_reportQuestionId1(v) {
		var selected  = document.getElementById('questionclassification');
		selected.options.length = 0;
		if(v == '' || v =='==请选择==') {
			selected.options.length = 0;
			var option = new Option('==请选择==', '');
			selected.options.add(option);
		} else {
			var objItemValue;
			var opText;
			if (v == '涉农专项资金') {
			    objItemValue = '以权谋私|以权谋私,优亲厚友|优亲厚友,虚报冒领|虚报冒领,套取、贪污、侵占涉农补贴资金|套取、贪污、侵占涉农补贴资金,其他|其他';
			} else if (v == '土地征收管理') {
			    objItemValue = '玩忽职守|玩忽职守,滥用职权|滥用职权,徇私舞弊|徇私舞弊,优亲厚友|优亲厚友,侵占截留|侵占截留,挪用私分|挪用私分,拖欠农民征地补偿款|拖欠农民征地补偿款,其他|其他';
			} else if (v == '城乡低保救助') {
			    objItemValue = '虚报冒领|虚报冒领,以权谋私|以权谋私,优亲厚友|优亲厚友,贪污侵占低保资金|贪污侵占低保资金,其他|其他';
			} else if (v == '社会保险基金') {
			    objItemValue = '虚报冒领|虚报冒领,重复领取|重复领取,滥用职权|滥用职权,以权谋私|以权谋私,优亲厚友|优亲厚友,贪污侵占|贪污侵占,缴纳不及时不足额|缴纳不及时不足额,其他|其他';
			} else if (v == "医疗卫生服务") {
			    objItemValue = '大处方|大处方,收红包|收红包,重复治疗|重复治疗,超标准收费|超标准收费,过度医疗|过度医疗,医保审查中吃拿卡要|医保审查中吃拿卡要,骗取城乡居民医保资金|骗取城乡居民医保资金,其他|其他';
			} else if (v == "中小学义务教育") {
			    objItemValue = '招收高价学生|招收高价学生,违规征订教辅材料|违规征订教辅材料,课上不讲课后讲|课上不讲课后讲,违规办班收费|违规办班收费,强制学生购买校服被褥|强制学生购买校服被褥,其他|其他';
			} else if (v == "小农水工程建设") {
			    objItemValue = '偷工减料|偷工减料,违规操作|违规操作,优亲厚友|优亲厚友,贪污侵占工程款|贪污侵占工程款,围标串标|围标串标,转包分包|转包分包,收受贿赂|收受贿赂,其他|其他';
			} else if (v == "农机购置补贴") {
			    objItemValue = '审核把关不严|审核把关不严,利益输送|利益输送,收受贿赂|收受贿赂,虚报冒领|虚报冒领,补贴兑付不及时、不到位|补贴兑付不及时、不到位,其他|其他';
			}
			opText = objItemValue.split(',');
			var option = new Option('==请选择==', '0');
			selected.options.add(option);
			for(var i = 0; i < opText.length; i++) {
				var item = new Option(opText[i].split('|')[1], selected);
	       		selected.options.add(item);
	       		//值和显示的内容
	       		item.value = opText[i].split('|')[0];
	       		item.text = opText[i].split('|')[1];
	       		item.title = opText[i].split('|')[1];
			}
		}
	}